<?php

 include_once "./utils/conn.php";

//  $sql="insert into student(stu_no,stu_name,sex,tel,major,class_name,hobby) values(?,?,?,?,?,?,?)";


//get user inputs
$stu_no=$_POST['stu_no'];
$stu_name=$_POST['stu_name'];
$sex=$_POST['sex'];
$tel=$_POST['tel'];
$major=$_POST['major'];
$class_name=$_POST['class_name'];
$hobby=$_POST['hobby'];

//拼凑sql语句
$sql="insert into student(stu_no,stu_name,sex,tel,major,class_name,hobby) values(";
$sql.="'".$stu_no."',";
$sql.="'".$stu_name."',";
$sql.="'".$sex."',";
$sql.="'".$tel."',";
$sql.="'".$major."',";
$sql.="'".$class_name."',";
$sql.="'".$hobby."')";

//执行sql
$result=mysqli_query($conn,$sql);
if($result){
    echo json_encode(["code"=>1,"msg"=>"数据保存成功"],JSON_UNESCAPED_UNICODE);
}